# CloudResearch 2 - Political Knowledge ----------------------------------------
A <- designMatrices(resp=cr2_pkscale)$A
A1 <- A
dimnames(A1)[[1]] <- colnames(cr2_pkscale)
A1[1,,] = A1[15,,]
A1[2,,] = A1[16,,]
A1[3,,] = A1[17,,]
A1[4,,] = A1[18,,]
A1[5,,] = A1[19,,]
A1[6,,] = A1[20,,]
A1[7,,] = A1[21,,]
A1[8,,] = A1[22,,]
A1[9,,] = A1[23,,]
A1[10,,] = A1[24,,]
A1[11,,] = A1[25,,]
A1[12,,] = A1[26,,]
A1[13,,] = A1[27,,]
A1[14,,] = A1[28,,]

cr2_pkscale_m <- tam.mml.2pl(cr2_pkscale,
                             group = cr2_language_group,
                             irtmodel = "2PL",
                             beta.fixed = cbind(c(1:3), 
                                                1, c(0, 0, 0)),
                             A = A1)

cr2_pkscale_m <- tam.mml.2pl(cr2_pkscale,
                             group = cr2_language_group,
                             irtmodel = "2PL",
                             beta.fixed = cbind(c(1:3), 
                                                1, c(0, 0, 0)),
                             A = A1,
                             xsi.fixed = cbind(which(cr2_pkscale_m$
                                                      xsi.fixed.estimated[,2]==0), 
                                               which(cr2_pkscale_m$
                                                      xsi.fixed.estimated[,2]!=0)))

cr2_pkscale_m2 <- tam.mml.2pl(cr2_pkscale,
                              group = cr2_language_group,
                              irtmodel = "2PL",
                              beta.fixed = cbind( c(1:3), 
                                                  1, c(0, 0, 0)))

cr2_pkscale_lr_sp <- IRT.compareModels(cr2_pkscale_m,
                                       cr2_pkscale_m2)

# CloudResearch 2 - Ideology --------------------------------------------------
A <- designMatrices(resp=cr2_ideology)$A
A1 <- A
dimnames(A1)[[1]] <- colnames(cr2_ideology)
A1[1,,] = A1[15,,]
A1[2,,] = A1[16,,]
A1[3,,] = A1[17,,]
A1[4,,] = A1[18,,]
A1[5,,] = A1[19,,]
A1[6,,] = A1[20,,]
A1[7,,] = A1[21,,]
A1[8,,] = A1[22,,]
A1[9,,] = A1[23,,]
A1[10,,] = A1[24,,]
A1[11,,] = A1[25,,]
A1[12,,] = A1[26,,]
A1[13,,] = A1[27,,]
A1[14,,] = A1[28,,]

cr2_ideology_m <- tam.mml.2pl(cr2_ideology,
                              group = cr2_language_group,
                              irtmodel = "2PL",
                              beta.fixed = cbind(c(1:3), 
                                                 1, c(0, 0, 0)),
                              A = A1)

cr2_ideology_m <- tam.mml.2pl(cr2_ideology,
                              group = cr2_language_group,
                              irtmodel = "2PL",
                              beta.fixed = cbind(c(1:3), 
                                                 1, c(0, 0, 0)),
                              A = A1,
                              xsi.fixed = cbind(which(cr2_ideology_m$
                                                       xsi.fixed.estimated[,2]==0), 
                                                which(cr2_ideology_m$
                                                       xsi.fixed.estimated[,2]!=0)))

cr2_ideology_m2 <- tam.mml.2pl(cr2_ideology,
                               group = cr2_language_group,
                               irtmodel = "2PL",
                               beta.fixed = cbind( c(1:3), 
                                                   1, c(0, 0, 0)))

cr2_ideology_lr_sp <- IRT.compareModels(cr2_ideology_m,
                                        cr2_ideology_m2)

